package com.capgemini.data;

import java.sql.Time;

import com.capgemini.daos.PersistableObject;

public class Performance implements PersistableObject {

	private Long id;

	private Time result;
	private int ranking;
	private boolean worldRecord;

	private long athlete;

	private Tournament tournament;

	public Performance() {
	}

	public Performance(Time result, int ranking, boolean worldRecord,
			Tournament tournament) {
		super();
		this.result = result;
		this.ranking = ranking;
		this.worldRecord = worldRecord;
		this.tournament = tournament;
	}

	public Long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Time getResult() {
		return result;
	}

	public void setResult(Time result) {
		this.result = result;
	}

	public int getRanking() {
		return ranking;
	}

	public void setRanking(int ranking) {
		this.ranking = ranking;
	}

	public boolean isWorldRecord() {
		return worldRecord;
	}

	public void setWorldRecord(boolean worldRecord) {
		this.worldRecord = worldRecord;
	}

	public long getAthlete() {
		return athlete;
	}

	public void setAthlete(long athlete) {
		this.athlete = athlete;
	}

	public Tournament getTournament() {
		return tournament;
	}

	public void setTournament(Tournament tournament) {
		this.tournament = tournament;
	}

	@Override
	public Class getEntityClass() {
		return Performance.class;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (athlete ^ (athlete >>> 32));
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ranking;
		result = prime * result
				+ ((this.result == null) ? 0 : this.result.hashCode());
		result = prime * result
				+ ((tournament == null) ? 0 : tournament.hashCode());
		result = prime * result + (worldRecord ? 1231 : 1237);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Performance other = (Performance) obj;
		if (athlete != other.athlete)
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (ranking != other.ranking)
			return false;
		if (result == null) {
			if (other.result != null)
				return false;
		} else if (!result.equals(other.result))
			return false;
		if (tournament == null) {
			if (other.tournament != null)
				return false;
		} else if (!tournament.equals(other.tournament))
			return false;
		if (worldRecord != other.worldRecord)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Performance [id=" + id + ", result=" + result + ", ranking="
				+ ranking + ", worldRecord=" + worldRecord + ", athlete="
				+ athlete + ", tournament=" + tournament + "]";
	}

	public String toPersistString() {
		return "Performance [id=" + id + ", result=" + result + ", ranking="
				+ ranking + ", worldRecord=" + worldRecord + ", athlete="
				+ athlete + "]";
	}

}
